package com.feihong.yw189.bluetooth.utils.util;

/**
 * @name djlm
 * @class name：com.android.djlmapp.utils
 * @class describe: 文本工具类
 * @anthor wangziheng
 * @time 2017/5/8 13:47
 * @change
 * @chang time
 * @class describe
 */
public class TextUtil {

    /**
     * 字节数组转换为字符串
     *      卡尔
     * @param src
     * @return
     */
    public static String bytesToASCString(byte[] src) {
        int len = src.length;

        if (src == null || len <= 0) {
            return null;
        }
        char[] result = new char[len];
        for (int i = 0; i < len; i++) {
            result[i] = (char) src[i];
        }

        return String.valueOf(result);
    }

    /**
     * 字节数组转字符串
     *          恒鸿达
     * @param bcd
     * @return
     */
    public static String bytesToHexStr(byte[] bcd) {
        StringBuffer s = new StringBuffer(bcd.length * 2);

        for (int i = 0; i < bcd.length; i++) {
            boolean[] bcdLookup = new boolean[0];
            s.append(bcdLookup[(bcd[i] >>> 4) & 0x0f]);
            s.append(bcdLookup[bcd[i] & 0x0f]);
        }

        return s.toString();
    }
}
